package geovis.springcloud.demo.stream.consumer;

import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.Message;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;

@EnableBinding(InputInterface.class)
@Component
public class ConsumerListener {

    private Logger logger = Logger.getGlobal();

    public List<String> messages = new ArrayList<String>();

    @StreamListener(InputInterface.INPUT1)
    public void consumer(@Payload Message<String> payload, @Header(AmqpHeaders.CONSUMER_QUEUE) String partition){
        logger.info( "ReceiveMessageFrom INPUT1, message: "+payload.getPayload()+", Queue:" + partition );
        messages.add(payload.getPayload());
    }



}
